package tech.aistar.corejava.day02;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:求出某年某月最大天数
 * 衍生题:给定year,month,date[具体的日] 2019 , 7  , 16
 * 求出这个日期在今年多少天!!!
 * @date 2019/7/16 0016
 */
public class ElseIfDemo {
    public static void main(String[] args) {
        //定义年份
        int year = 2012;
        //定义月份
        int month = 2;

        //定义天数
        int maxDays = -1;

        //判断month
        if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){
            maxDays = 31;
        }else if(month == 2){
//            maxDays = 28;
//            //闰年...
//            if((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0 ))
//                maxDays++;

            boolean flag = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0 );

            maxDays = flag ? 29 : 28;

        }else{
            maxDays = 30;
        }
        System.out.println(year+"年"+month+"月,最大天数是:"+maxDays);
    }
}
